home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15429 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1009 b   |  45 lines

  1. Path: news.compuserve.com!user
  2. From: 101641.317@compuserve.com (Martin Mamo)
  3. Newsgroups: comp.lang.c
  4. Subject: Why are &apple and apple, where apple is an array, the same
  5. Date: Thu, 18 Apr 1996 23:08:25 +0000
  6. Organization: none
  7. Distribution: world
  8. Message-ID: <AD9C7BE9966828AF7@ad49-131.compuserve.com>
  9. NNTP-Posting-Host: ad49-131.compuserve.com
  10.  
  11. The following C program contains two printf's. They both
  12. give the same answer, despite the fact one gives the
  13. value of apple and the other &apple.
  14.  
  15. I know in C, an array variable is the address of the
  16. first element. So why do C compilers on both Macs and PCs
  17. allow you to take an address of an address? Why does
  18. apple and &apple, where apple is an array variable, give
  19. the same result.
  20.  
  21. Please can you reply by e-mail to me as well, as I check
  22. newsgroups less often than my e-mail. Thanks.
  23.  
  24. Martin
  25. 101641.317@compuserve.com
  26.  
  27.  
  28. #include <stdio.h>
  29.  
  30. void main(void)
  31. {
  32.  
  33.     char apple[10];
  34.     apple[0] = 0;
  35.     
  36.     printf( "%lu\n", apple );
  37.  
  38.     printf(" %lu\n", &apple );
  39.  
  40.  
  41. }
  42.  
  43.  
  44.  
  45.